package com.zqh.productquery.controller;

import com.zqh.myfmmall.result.Result;
import com.zqh.productquery.service.ProductQueryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description :
 * @Author :kono淇杭哒、
 * @Create 2022-02-18 2:15
 */
@RestController
@RequestMapping("product")
public class ProductQueryController{
    @Resource
    private ProductQueryService productQueryService;


    @PostMapping("getByIds")
    public Result getByIds(@RequestBody List<String> ids){
        return Result.success(productQueryService.listByIds(ids));
    }

    @GetMapping("retrieve/{id}")
    public Result retrieve(@PathVariable("id") String id){
        return Result.success(productQueryService.getById(id));
    }

    @GetMapping("rootCategoryHighestSellingVo/{rootCategoryId}")
    public Result rootCategoryHighestSelling(@PathVariable("rootCategoryId") String rootCategoryId){
        return productQueryService.rootCategoryHighestSelling(rootCategoryId);
    }

    @GetMapping("retrieveHighestSellingVo/{categoryId}")
    public Result retrieveHighestSellingVo(@PathVariable("categoryId") String categoryId){
        return productQueryService.highestSellingProduct(categoryId);
    }

    @GetMapping("retrieveLatestVo/{categoryId}")
    public Result retrieveLatest(@PathVariable("categoryId") String categoryId){
        return productQueryService.latestProduct(categoryId);
    }
}
